package com.example.mybaiduweishi.fragments.base;

import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import butterknife.ButterKnife;
import butterknife.Unbinder;

/**
 * Created by Administrator on 2017/5/26 0026.
 */

public abstract class BaseFragmentbase extends Fragment {

    private View view;
    Unbinder unbinder;



    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(getXML(), container, false);
        }
        unbinder=ButterKnife.bind(this,view);
        initView();
        initData();


        return view;

    }

    public abstract int getXML();

    //实例化视图
    public abstract void initView();



    //初始化数据
    public abstract void initData();

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        if (unbinder!=null){
            unbinder.unbind();
        }
    }


}
